import moduleRegist from '@/utils/moduleRegist';
import {
  module as roleModule
} from './module';
import {
  module as permissionModule
} from '../Permission/module';
const ListView = resolve => {
  require(['./ListView'], resolve);
};

const Layout = resolve => {
  require(['./Layout'], resolve);
};

const AddForm = resolve => {
  require(['./AddForm'], resolve);
};

const EditForm = resolve => {
  require(['./EditForm'], resolve);
};

export default [
  /** 配置管理路由 */
  {
    path: 'role',
    redirect: 'role/list',
    component: Layout,
    meta: {
      title: '角色',
      name: '角色',
      permission: 'auth:menu:role:list',
      componentName: 'RoleLayout',
      keepAlive: true,
      icon: 'md-people',
      show: false
    },
    beforeEnter: (to, from, next) => {
      moduleRegist(roleModule);
      moduleRegist(permissionModule);
      next();
    },
    children: [{
      path: 'list',
      component: ListView,
      meta: {
        title: '角色列表',
        name: '角色',
        breadcrumb: '角色列表',
        permission: 'auth:role:query',
        keepAlive: true,
        componentName: 'RoleListView',
        icon: 'md-people'
      }
    }, {
      path: 'add',
      component: AddForm,
      meta: {
        title: '添加角色',
        name: '添加角色',
        breadcrumb: '添加角色',
        permission: 'auth:role:add',
        show: false,
        keepAlive: true,
        componentName: 'RoleAddView',
        icon: 'md-people'
      }
    }, {
      path: 'edit/:id',
      component: EditForm,
      meta: {
        title: '修改角色',
        name: '修改角色',
        breadcrumb: '修改角色',
        permission: 'auth:role:edit',
        show: false,
        keepAlive: false,
        componentName: 'RoleEditView',
        icon: 'md-people'
      }
    }]
  }
];
